<!--
 * @Description: 
 * @Version: 1.0
 * @Autor: gaoluo
 * @Date: 2021-11-12 09:24:24
 * @LastEditors: gaoluo
 * @LastEditTime: 2021-11-16 09:31:40
 * @FilePath: /nhw/src/views/Work/EmergencyManagement/EmergencyGoodsDetails.vue
-->
<template>
  <Layout class="emergency-goods-details-container" title="应急物资" border>
    <List
      v-model="loading"
      :finished="finished"
      finished-text="没有更多了"
      @load="onLoad"
      v-if="emList.length > 0"
    >
      <Card v-for="item in emList" :key="item.eegId">
        <CardTitle text="物资编号" adorn :listId="item.eegId" />
        <CardTwig left="物资名称" :right="item.eegName" colon />
        <CardTwig left="物资类别" :right="item.egtName" colon />
        <CardTwig left="主管部门" :right="item.departName" colon />
        <CardTwig left="数量" :right="item.num" colon />
      </Card>
    </List>
    <Empty description="该仓库为空" v-else />
  </Layout>
</template>

<script>
import Layout from "components/Layout";
import Card from "components/Card";
import CardTwig from "components/Card/CardTwig";
import CardTitle from "components/Card/CardTitle";
import { Empty, List } from "vant";
import { getDrillOtherSubList } from "@/api/work";
export default {
  name: "EmergencyGoodsDetails",
  components: {
    Layout,
    Card,
    CardTwig,
    CardTitle,
    Empty,
    List,
  },
  data() {
    return {
      orgNo: "",
      loading: false,
      finished: false,
      pageNum: 1,
      emList: [],
    };
  },
  created() {
    this.orgNo = window.localStorage.getItem("orgNo");
    this.getDrillOtherSubList().then((res) => {
      this.emList = res;
    });
  },

  methods: {
    onLoad() {
      this.pageNum++;
      this.getDrillOtherSubList().then((res) => {
        this.emList.push(...res);
      });
    },
    async getDrillOtherSubList() {
      const res = await getDrillOtherSubList({
        orgNo: this.orgNo,
        pageSize: 10,
        pageNum: this.pageNum,
        no: this.$route.params.data.eegNo,
      });

      if (res.param.sumPage <= this.pageNum) {
        this.finished = true;
      }
      return res.param.data;
    },
  },
};
</script>

<style lang="scss" scoped>
</style>